#include <stdio.h>
#include <sqlite3.h>

int main(int argc, char const *argv[])
{
    sqlite3* db = NULL;
    int ret = sqlite3_open("1.db",&db);
    if (ret != SQLITE_OK)
    {
        printf("sqlite3_open err\n");
        return 0;
    }

    printf("open success\n");

    char name[64]={'\0'};
    gets(name);
    char buf[256] = {'\0'};
    sprintf(buf,"insert into stu values(7,'%s',66);",name);

    char* errmsg = NULL;
    ret = sqlite3_exec(db,buf,NULL,NULL,&errmsg);
    if (ret!=SQLITE_OK)
    {
        printf("err = %s\n",errmsg);
        sqlite3_free(errmsg);
        return -1;
    }
    

    sqlite3_close(db);

    printf("close success\n");
      
    return 0;
}
